package com.zkthink.ceres.app.comment.controller;

import com.zkthink.base.R;
import com.zkthink.ceres.applet.comment.service.AppletCommentService;
import com.zkthink.ceres.order.dto.comment.*;
import com.zkthink.ceres.order.entity.Comment;
import com.zkthink.ceres.order.service.CommentService;
import com.zkthink.ceres.order.vo.comment.CommentPageVO;
import com.zkthink.context.BaseContextHandler;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@Validated
@RestController
@RequestMapping("/comment")
@Api(value = "评价接口", tags = "评价接口")
@AllArgsConstructor
public class CommentController {

    private CommentService commentService;
    
    @Resource
    private AppletCommentService appletCommentService;

    @ApiOperation("发表评价接口")
    @PostMapping("/publishComment")
    public R<Boolean> publishComment(@RequestBody PublishCommentDTO dto){
        dto.setMid(BaseContextHandler.getUserId());
        return commentService.publishComment(dto);
    }
    @ApiOperation("我的评价")
    @GetMapping("/myComment")
    public R myComment(){
        //return commentService.myComment();
        return appletCommentService.findMyComment();
    }
    @ApiOperation("假删除删除评价")
    @GetMapping("delect/{id}")
    public R delect(@PathVariable("id") Long id){
        //return commentService.delect(id);
        return appletCommentService.deleteById(id);
    }








//    @ApiOperation("评价接口")
//    @PostMapping("/comment")
//    public R<Boolean> comment(@RequestBody Comment comment){
//        comment.setMid(BaseContextHandler.getUserId());
//        return commentService.comment(comment);
//    }

//    @ApiOperation("追评接口")
//    @PostMapping("/additionalComment")
//    public R<Boolean> additionalComment(@RequestBody Comment comment){
//        comment.setMid(BaseContextHandler.getUserId());
//        return commentService.additionalComment(comment);
//    }
//
//    @ApiOperation("点赞或取消点赞某个评论")
//    @PostMapping("/likeOrUnlikeComment")
//    public R<Boolean> likeOrUnlikeComment(@RequestBody LikeCommentDTO likeCommentDTO){
//        likeCommentDTO.setMid(BaseContextHandler.getUserId());
//        return commentService.likeOrUnlikeComment(likeCommentDTO);
//    }

    @ApiOperation("查看我的评论列表")
    @PostMapping("/findMyCommentList")
    public R<CommentPageVO> findMyCommentList(@RequestBody QueryCommentDTO queryCommentDTO){
        queryCommentDTO.setMid(BaseContextHandler.getUserId());
        return commentService.findMyCommentList(queryCommentDTO);
    }

    @ApiOperation("查看商品或店铺的评论列表")
    @PostMapping("/findProductStoreCommentList")
    public R<CommentPageVO> findProductStoreCommentList(@RequestBody QueryProductOrStoreCommentDTO commentDTO){
        commentDTO.setMid(BaseContextHandler.getUserId());
        return commentService.findProductStoreCommentList(commentDTO);
    }

}
